package com.beiing.tianshuai.tianshuai.interest.presenter;

import com.beiing.tianshuai.tianshuai.base.BasePresenter;
import com.beiing.tianshuai.tianshuai.entity.CodeBean;
import com.beiing.tianshuai.tianshuai.interest.entity.InterestCategoriesBean;
import com.beiing.tianshuai.tianshuai.interest.model.InterestPublishModel;
import com.beiing.tianshuai.tianshuai.interest.model.InterestPublishModelImpl;
import com.beiing.tianshuai.tianshuai.interest.view.InterestPublishViewImpl;

import java.io.File;

/**
 * Created by Jinni on 2017/11/30 0030
 */

public class InterestPublishPresenter extends BasePresenter
        implements InterestPublishPresenterImpl,
        InterestPublishModel.OnInterestPublishResponseListener {

    private InterestPublishViewImpl mView;
    private InterestPublishModelImpl mModel;

    public InterestPublishPresenter(InterestPublishViewImpl view) {
        mView = view;
        mModel = new InterestPublishModel(this);
    }

    @Override
    public void getCategories() {
        mView.showProgress();
        mModel.getCategories();
    }

    @Override
    public void submitVideo(String uid, String tid, String title, String content, String url, File cover) {
        mView.showProgress();
        mModel.submitVideo(uid, tid, title, content, url, cover);
    }

    @Override
    public void onGetCategoriesSuccess(InterestCategoriesBean bean) {
        mView.hideProgress();
        mView.onRequestSuccess(bean);
    }

    @Override
    public void onGetCategoriesError(Throwable throwable) {
        mView.hideProgress();
        mView.onRequestFailed(throwable);
    }

    @Override
    public void onSubmitSuccess(CodeBean bean) {
        mView.hideProgress();
        mView.submitVideoSuccess(bean);
    }

    @Override
    public void onSubmitError(Throwable e) {
        mView.hideProgress();
        mView.submitVideoError(e);
    }
}
